home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Magnum One
/
Magnum One (Mid-American Digital) (Disc Manufacturing).iso
/
d3
/
edit1234.arc
/
EDIT1234.BAS
< prev
next >
Wrap
BASIC Source File
|
1991-04-28
|
12KB
|
349 lines
'*************************************************
'THIS IS NOT A FUNCTIONAL PROGRAM
'It is a collection of four editors, ranging from a simple pressing the
'<enter> Key to a Full feature Editor.
'Comments, Questions, Suggestions would be appreciated. Leave Message
'for GAYLON HILL at 615-966-3574 or CompuServe 73500,2521
'***************************************************
'*********************** FIRST EDITOR
'sample program [ index.bas ] included to show how editor is used
'author George Jones
DECLARE SUB OneEditScreen
EditorOne:
GET #1, rn%, Alpha
'call on screen instructions, display the record, etc
OneEditScreen
LOCATE 16, 18: LINE INPUT New$
'if no change - press <enter> if new string is "" then string is not changed
'if new string is greater than zero then Old$ is changed to New$
IF LEN(New$) <> 0 THEN Alpha.NField = New$
LOCATE 16, 50: LINE INPUT NewPage$
IF LEN(NewPage$) <> 0 THEN Alpha.Page = NewPage$
PUT #1, rn%, Alpha
'display the edited record
RETURN DispNames
'********************************
'****************************EDITOR TWO - 1500 bytes
'sample program cards.bas is included to show how editor is used
'author George Jones
DECLARE SUB EditorTwoOverlay ()
DECLARE SUB GetKeyPress (Edit$)
EditTwo:
GET #1, rn%, Easy
'call the instructions, display record to be edited, etc
EditorTwoOverlay
x% = 17: LOCATE x%, 6:
'How long is the string to be edited?
Edit$ = Easy.Last: CALL GetKeyPress(Edit$)
'Check for Key - either <Esc> or <enter>
'if <enter> Key is pressed, accept this field as is and go to next field
'if <Esc> Key is pressed, then editor is activated - Input new data
'for first field of the record
IF Edit$ <> "" THEN
LINE INPUT Easy.Last
'If new data is "zzz" then tag record and restore to file
'skip the other fields - leave them unchanged
IF LEFT$(UCASE$(Easy.Last), 3) = "ZZZ" THEN
Easy.Last = "zzz{del}" + LEFT$(Edit$, 7)
PUT #1, rn%, Easy
'display the record which is now tagged for deletion
RETURN DispName
END IF
END IF
LOCATE x%, 36:
'again, how long is the string to be edited
Edit$ = Easy.First: CALL GetKeyPress(Edit$)
'again which key was pressed? <enter> or <Esc>
IF Edit$ <> "" THEN LINE INPUT Easy.First
Spot 2, 6: Edit$ = Easy.Addr: CALL GetKeyPress(Edit$)
IF Edit$ <> "" THEN LINE INPUT Easy.Addr
Spot 2, 6: Edit$ = Easy.City: CALL GetKeyPress(Edit$)
IF Edit$ <> "" THEN LINE INPUT Easy.City
LOCATE x%, 31: Edit$ = Easy.State: CALL GetKeyPress(Edit$)
IF Edit$ <> "" THEN LINE INPUT Easy.State
LOCATE x%, 46: Edit$ = Easy.Zip: CALL GetKeyPress(Edit$)
IF Edit$ <> "" THEN LINE INPUT Easy.Zip
Spot 2, 6: Edit$ = Easy.Remk: CALL GetKeyPress(Edit$)
IF Edit$ <> "" THEN LINE INPUT Easy.Remk
Easy.CarrRetn = CHR$(13) + CHR$(10)
PUT #1, rn%, Easy
RETURN DispName
'*********************EDITOR THREE - 1600 bytes - Similiar to Editor Four
'but smaller, with fewer functions
'author Gaylon Hill
DECLARE SUB ThirdEditor (Row, Col, Text$, TextLen)
CALL ThirdEditor(Row, Col, Text$, TextLen)
'documentation for this editor is included inside Sub ThirdEditor
'**********************
'*********************EDITOR FOUR - 4000 bytes
'author Gaylon Hill
DECLARE SUB FourthEditor (Row, Col, RCol, Text$, TextType$, TextLen, Ccode)
CALL FourthEditor(Row, Col, RCol, Text$, TextType$, TextLen, Ccode)
'documentation for Fourth Editor is included inside Sub Fourth Editor
'**********************
"****END OF PROGRAM, ETC*******
SUB EditorTwoOverlay
Upper "T H E E D I T S C R E E N"
x% = 3: Center 1, "To Leave an Item Unchanged, Press <enter>"
Center 1, "┌┤ To Correct an Item - Press <Esc> to Enable the EDITOR; ├┐"
Center 1, "└┤then type New Data - Press <Enter> - Repeat for each Field├┘"
COLOR 1, 7
Center 2, "To delete this record, EDIT in " + CHR$(34) + "ZZZ" + CHR$(34) + " as Last Name and Press <enter>"
Spot 3, 26: COLOR 15, 1: PRINT RTRIM$(Easy.Last); ", "; Easy.First
Spot 1, 26: PRINT Easy.Addr
Spot 1, 26: PRINT RTRIM$(Easy.City); ", "; Easy.State; ", "; Easy.Zip
Spot 1, 26: PRINT Easy.Remk
Spot 3, 6: COLOR 1, 7: PRINT Easy.Last: LOCATE x%, 36: PRINT Easy.First
Spot 2, 6: PRINT Easy.Addr: Spot 2, 6: PRINT Easy.City;
LOCATE x%, 31: PRINT Easy.State; : LOCATE x%, 46: PRINT Easy.Zip
Spot 2, 6: PRINT Easy.Remk
END SUB
DEFINT A-Z
'
SUB FourthEditor (Row, Col, RCol, Text$, TextType$, TextLen, Ccode)
'This editor is similiar to a word processor.
'Row = the screen row
'Col = the screen col
'RCol = the right far col
'Text$ = the text that is send and returned from the edit line
'TextType$ = the type of accepted text in string form
' Example: TextType$ = "0123456789". If Text$Type$ = ""
' then character 32 to 254 is accepted.
'TextLen = the length of the Text$ to be edit
'Ccode = returned positive number of the key that was used
' to exit the edit call
CONST BACKSPACE = 8, TABKEY = 9, ENTER = 13, DELWORD = 20, ESC = 27
CONST DELALL = 25, DOWN = -80, HOME = -71, UP = -72, PGUP = -73
CONST LEFT = -75, RIGHT = -77, ENDKEY = -79, PGDN = -81, INS = -82
CONST DEL = -83, WORDLEFT = -115, WORDRIGHT = -116
CONST CONTROLEND = -117, CONTROLHOME = -119
CONST F1 = -59, F2 = -60, F3 = -61, F4 = -62, F5 = -63
CONST F6 = -64, F7 = -65, F8 = -66, F9 = -67, F10 = -68
Ttext$ = LEFT$(Text$ + STRING$(TextLen, 32), TextLen)
cPos = LEN(Text$) + 1
TRUE = 1: InSert = -1
DO
LLen = RCol - Col
NRow = CINT(TextLen / LLen + .5)
Cr = cPos \ LLen + 1
IF Cr > 1 THEN
Cp = (cPos MOD (Cr - 1) * LLen)
IF Cp = 0 THEN
Cr = Cr - 1
Cp = LLen
END IF
ELSE
Cp = cPos
END IF
R = Row
FOR x = 1 TO NRow
LOCATE R, Col: PRINT MID$(Ttext$, x * LLen - LLen + 1, LLen);
R = R + 1
NEXT
LOCATE Row + Cr - 1, Col + Cp - 1
DO
i$ = INKEY$
LOOP UNTIL LEN(i$)
IF LEN(i$) = 1 THEN
KeyC = ASC(i$)
ELSE
KeyC = -ASC(RIGHT$(i$, 1))
END IF
SELECT CASE KeyC
CASE 32 TO 254
IF INSTR(TextType$, i$) = 0 AND TextType$ <> "" THEN
ELSE
IF cPos <= TextLen AND InSert THEN
Ttext$ = LEFT$(Ttext$, cPos - 1) + i$ + MID$(Ttext$, cPos, TextLen - cPos)
cPos = cPos + 1
END IF
IF cPos <= TextLen AND NOT InSert THEN
MID$(Ttext$, cPos, 1) = i$
cPos = cPos + 1
END IF
END IF
CASE BACKSPACE
IF cPos > 1 THEN
cPos = cPos - 1
Ttext$ = LEFT$(Ttext$, cPos - 1) + MID$(Ttext$, cPos + 1, TextLen - cPos) + " "
END IF
CASE DEL
Ttext$ = LEFT$(Ttext$, cPos - 1) + MID$(Ttext$, cPos + 1, TextLen - cPos) + " "
CASE DELALL
Ttext$ = STRING$(TextLen, 32)
cPos = 1
CASE DELWORD
FOR xx = cPos TO TextLen
x$ = MID$(Ttext$, xx, 1)
IF x$ < CHR$(48) OR x$ > CHR$(122) THEN
Ttext$ = LEFT$(Ttext$, cPos - 1) + MID$(Ttext$, xx, TextLen - xx + 1) + STRING$(xx - cPos, 32)
EXIT FOR
END IF
NEXT
IF xx = TextLen + 1 THEN
Ttext$ = LEFT$(Ttext$, cPos - 1) + STRING$(TextLen - cPos + 1, 32)
END IF
IF xx = cPos THEN
Ttext$ = LEFT$(Ttext$, cPos - 1) + MID$(Ttext$, cPos + 1, TextLen - cPos) + " "
END IF
CASE ENDKEY
FOR xx = TextLen TO 1 STEP -1
IF MID$(Ttext$, xx, 1) > CHR$(32) THEN
cPos = xx + 1
EXIT FOR
END IF
NEXT
CASE CONTROLEND, CONTROLHOME, ESC, PGDN, PGUP, TABKEY, F1, F2, F3, F4, F5, F6, F7, F8, F9, F10
GOTO ExitRoutine
CASE ENTER
Cr = (cPos / LLen + .5)
cPos = Cr * LLen + 1
IF cPos > TextLen THEN
GOTO ExitRoutine
END IF
CASE UP
cPos = cPos - LLen
IF cPos < 1 THEN
GOTO ExitRoutine
END IF
CASE DOWN
cPos = cPos + LLen
IF cPos > TextLen THEN
GOTO ExitRoutine
END IF
CASE HOME
cPos = 1
CASE INS
InSert = NOT InSert
CASE LEFT
IF cPos > 1 THEN
cPos = cPos - 1
END IF
CASE RIGHT
IF cPos < TextLen THEN
cPos = cPos + 1
END IF
CASE WORDLEFT
IF cPos > 1 THEN
FOR xx = cPos - 1 TO 1 STEP -1
IF MID$(Ttext$, xx, 1) > CHR$(32) THEN
sw = 1
END IF
IF sw = 1 AND MID$(Ttext$, xx, 1) = CHR$(32) THEN
cPos = xx + 1: sw = 0
EXIT FOR
END IF
NEXT
IF xx = 0 THEN
cPos = 1: sw = 0
END IF
END IF
CASE WORDRIGHT
FOR xx = cPos TO TextLen
IF MID$(Ttext$, xx, 1) = CHR$(32) THEN
sw = 1
END IF
IF sw = 1 AND MID$(Ttext$, xx, 1) > CHR$(32) THEN
cPos = xx: sw = 0
EXIT FOR
END IF
NEXT
CASE ELSE
END SELECT
LOOP WHILE TRUE
ExitRoutine:
Ccode = ABS(KeyC)
Text$ = RTRIM$(Ttext$)
END SUB
DEFSNG A-Z
SUB GetKeyPress (Edit$)
x% = CSRLIN
p% = POS(0)
ss% = LEN(Edit$)
LOCATE x%, p%: COLOR 7, 0: PRINT Edit$
LOCATE x%, p%
DO
K$ = INKEY$
IF K$ = CHR$(13) THEN
COLOR 0, 7: PRINT Edit$
Edit$ = ""
EXIT SUB
END IF
LOOP WHILE K$ <> CHR$(27)
IF K$ = CHR$(27) THEN
COLOR 15, 4: PRINT SPACE$(ss%)
LOCATE x%, p%, 1
END IF
END SUB
SUB OneEditScreen
COLOR 0, 1, 8: CLS : Upper "T H E E D I T S C R E E N"
Center 2, "To accept NAME, or PAGE, as written, Press <enter>"
Center 2, "To CORRECT either NAME or PAGE , re-type entry and Press <enter>"
Center 2, "To DELETE this record - Type " + CHR$(34) + "ZZZ" + CHR$(34) + " for Name and Press <enter> "
Spot 2, 15: COLOR 15, 4: PRINT " E d i t i n g R e c o r d N u m b e r"
LOCATE x%, 60: COLOR 15, 0: PRINT rn%
Spot 2, 18: COLOR 0, 2: PRINT "N A M E "
LOCATE x%, 50: PRINT "P A G E"
Spot 2, 18: COLOR 0, 7: PRINT Alpha.NField;
LOCATE x%, 50: COLOR 1, 7: PRINT Alpha.Page
END SUB
DEFINT A-Z
'
SUB ThirdEditor (Row, Col, Text$, TextLen)
'Row = the screen row
'Col = the screen col
'Text$ = the text that is send and returned from the edit line
'TextLen = the length of the Text$ to be edit
DO
LOCATE Row, Col: PRINT Text$;
LOCATE Row, Col + cPos - 1
DO
KeyC$ = INKEY$
LOOP UNTIL LEN(KeyC$)
SELECT CASE ASC(KeyC$)
CASE 32 TO 254
IF cPos <= TextLen THEN
MID$(Text$, cPos, 1) = KeyC$
cPos = cPos + 1
END IF
CASE 8
IF cPos > 1 THEN
cPos = cPos - 1
Text$ = LEFT$(Text$, cPos - 1) + MID$(Text$, cPos + 1, TextLen - cPos) + " "
END IF
CASE 13
LOCATE , , 0
Text$ = RTRIM$(Text$)
EXIT SUB
END SELECT
LOOP
END SUB